﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HA.ModFlow.Domain.DomainLayer;
using HAUtil;

namespace HA.Data
{
    [Serializable]
   public class GridFrame:DescEntity,ICloneable
    {

        public GridFrame()
        {
            this._xOrg = 0;
            this._yOrg = 0;

            this._zOrg = 0;

            this._xLength=100;
            this._yLength = 100;
            this._zLength = 10;


            this._rotateAngle = 0;

            this.Name = "网格边框";
 

        }


        #region 事件模型

        //[field:NonSerialized]
        //public event EventHandler GridFrameChanged;


        #endregion


        double _xOrg;

        public double XOrg
        {
            get { return _xOrg; }
            set { _xOrg = value; }
        }
        double _yOrg;

        public double YOrg
        {
            get { return _yOrg; }
            set { _yOrg = value; }
        }


        double _zOrg;

        public double ZOrg
        {
            get { return _zOrg; }
            set { _zOrg = value; }
        }



        double _xLength;

        public double XLength
        {
            get { return _xLength; }
            set { _xLength = value; }
        }
        double _yLength;

        public double YLength
        {
            get { return _yLength; }
            set { _yLength = value; }
        }

        double _zLength=1;

        public double ZLength
        {
            get { return _zLength; }
            set { _zLength = value; }
        }


        double _rotateAngle;

        public double RotateAngle
        {
            get { return _rotateAngle; }
            set { _rotateAngle = value; }
        }

        public void EditGridFrame(double orgX,double orgY,double width,double height,double rotation)
        {
            this._xOrg = orgX;
            this._yOrg = orgY;

            this._xLength = width;
            this._yLength = height;

            this._rotateAngle = rotation;


            ///未定义主程事件
            ///

            //if (GridFrameChanged!=null)
            //{
            //    GridFrameChanged(this,new EventArgs ());
                
            //}
        }
        public object  Clone()
        {
            GridFrame grid = new GridFrame();
           grid=(GridFrame) this.MemberwiseClone();
           return grid;
        }


        public static bool operator ==(GridFrame sp1, GridFrame sp2)
        {
            // check for both null (cast to object or recursive loop)
            if ((object)sp1 == null && (object)sp2 == null)
            {
                return true;
            }

            // check for either of them == to null
            if ((object)sp1 == null || (object)sp2 == null)
            {
                return false;
            }

            

          


            if (sp1._xOrg != sp2._xOrg || sp1._yOrg != sp2._yOrg || sp1._zOrg != sp2._zOrg || sp1._xLength != sp2._xLength || sp1._yLength != sp2._yLength || sp1._zLength != sp2._zLength || sp1._rotateAngle != sp2._rotateAngle)
            {
                return false;

            }
            else
            {
                return true;
            }

        }

        public static bool operator !=(GridFrame sp1, GridFrame sp2)
        {

            return (!(sp1 == sp2));



            //if (sp1==null||sp2==null)
            //{
            //    return true;
                
            //}



            //if (sp1._xOrg != sp2._xOrg || sp1._yOrg != sp2._yOrg || sp1._zOrg != sp2._zOrg || sp1._xLength != sp2._xLength || sp1._yLength != sp2._yLength || sp1._zLength != sp2._zLength || sp1._rotateAngle != sp2._rotateAngle)
            //{
            //    return true;

            //}
            //else
            //{
            //    return false;
            //}

        }



    }
}
